package com.itheima.blog.admin.config;

import com.itheima.blog.admin.interceptor.UserInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Component
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        UserInterceptor userInterceptor = new UserInterceptor();
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/v2/api-docs")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/*.html")
                .excludePathPatterns("/swagger-resources")
                //放行部分用于feign调用的接口 -- 2个用户登录后请求头设置的名字不同
                .excludePathPatterns("/tag/**")
                .excludePathPatterns("/category/**")
        ;
    }
}
